#include<SuperOF.h>
using namespace std;
struct XY{
	int x,y;
}; 
int main()
{
	cout<<"in file name:";
	string a;
	cin>>a;
	a+=".ixy";
	cout<<"is this your file?   -"<<a<<endl;
	cout<<" 1.Y 2.N"<<endl;
	int b;
	cin>>b;
	if(b!=1)
	{
		color("yellow-d","black",0,0);
		cout<<"[W]program stoped"<<endl;
		cout<<"[W]close in 3 seconds"<<endl;
		Sleep(3000);
		return 0;
	}
	cout<<"each step wait time:";
	int swt;
	cin>>swt;
	cout<<"each round wait time:";
	int twt;
	cin>>twt;
	cout<<"how many round:";
	int round;
	cin>>round;
	freopen(a.c_str(),"r",stdin);
	XY xy[1001];
	int place;
	cin>>place;
	cout<<"[I]cin->place:"<<place<<endl;
	if(place<0 || place>=1000)
	{
		color("red-l","black",0,0);
		cout<<"[E]more than 999 spots"<<endl;
		cout<<"[W]close in 3 seconds"<<endl;
		Sleep(3000);
	}
	for(int i=1;i<=place;i++)
	{
		cin>>xy[i].x>>xy[i].y;
		cout<<"[I]cin->x:"<<xy[i].x<<" y:"<<xy[i].y<<endl;
	}
	cout<<"[I]cin finish"<<endl;
	cout<<"[I]begin in 3 seconds"<<endl;
	Sleep(3000);
	cout<<"[I]working"<<endl;
	for(int i=1;i<=round;i++)
	{
		for(int j=1;j<=place;j++)
		{
            cout<<"[I]start round "<<i<<endl;
			cout<<"[I]round:"<<i<<" spot:"<<j<<endl;
			cout<<"[I]move to "<<xy[j].x<<","<<xy[j].y<<endl;
			SetCursorPos(xy[j].x,xy[j].y);
			cout<<"[I]chicking..."<<endl;
			mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
			mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
			cout<<"[I]spot "<<j<<":finish"<<endl;
			Sleep(swt);
			if(GetKeyState(VK_CONTROL))
			{
				cout<<"[I]program stopping"<<endl;
				color("yellow-d","black",0,0);
				cout<<"[W]close in 3 seconds"<<endl;
				Sleep(3000);
				return 0;
			}
		}
		cout<<"[I]finish round "<<i<<endl;
		Sleep(twt);
	}
	cout<<"[I]Finish."<<endl;
	Sleep(5000);
	return 0;
}

